import React, { Component } from 'react'
// import qs from 'querystring'

const detailData = [
  { id: 1, content: 'Java' },
  { id: 2, content: 'JavaScript' },
  { id: 3, content: 'React' }
]
export default class Detail extends Component {
  render() {
    // 接收params参数
    const { id, title } = this.props.match.params

    // 接收search参数
    // const { search } = this.props.location
    // const { id, title } = qs.parse(search.slice(1))

    // 接收state参数
    // console.log(this.props)
    // const { id, title } = this.props.location.state || {}

    const result =
      detailData.find((data) => {
        return data.id == id
      }) || {}

    return (
      <div>
        <ul>
          <li>ID: {id}</li>
          <li>Title: {title}</li>
          <li>Content: {result.content}</li>
        </ul>
      </div>
    )
  }
}
